package com.meixiang.dialog;


import android.view.View;
import android.widget.TextView;

import com.meixiang.R;
import com.meixiang.main.MXApplication;
import com.meixiang.tool.Tool;
import com.meixiang.util.AbToastUtil;
import com.meixiang.view.ClearEditText;
import com.meixiang.view.photoSelectActivity.util.Bimp;

import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2016/5/20.
 */
public class GiveUpDialogFragment extends BaseDialogFragment{

    public static String TAG = "GiveUpDialogFragment";
    private TextView tvText1,tvText2;
    private ClearEditText mTvEditingText;
    public GiveUpDialogFragment(){

    }

    public static GiveUpDialogFragment getIntanceDialog(){

        return new GiveUpDialogFragment() ;
    }

    @Override
    protected int setFragmentViewId() {
        return R.layout.dialog_give_up_edit;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);
    }

    @Override
    protected void initView(View rootView) {
        ButterKnife.bind(this,rootView);
        mTvEditingText= (ClearEditText) getActivity().findViewById(R.id.tv_editing_text);
    }

    @Override
    protected void initData() {

    }

    @OnClick({R.id.tv_save,R.id.tv_give_up,R.id.tv_option})
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.tv_save:
                dismiss();
                MXApplication.mApp.getSession().set("save", mTvEditingText.getText().toString());
                AbToastUtil.showToast(getContext(),"保存成功");
                getActivity().finish();
                break;

            case R.id.tv_give_up:
                dismiss();
                Tool.showTextToast(getActivity(), "放弃编辑");
                mTvEditingText.setText("");
                MXApplication.mApp.getSession().set("save", mTvEditingText.getText().toString());
                //放弃保存，清空选择图片集合
                if( Bimp.tempSelectBitmap.size()>0){
                    Bimp.tempSelectBitmap.clear();
                }
                getActivity().finish();
                break;

            case R.id.tv_option:
                dismiss();
                break;
        }
    }
}
